 #coding=utf-8
import socket
import time
# 创建一个 TCP/IP socket
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# 绑定 IP 地址和端口号
server_address = ('0.0.0.0', 8888)
server_socket.bind(server_address)

# 开始监听连接请求
server_socket.listen(1)

print('等待客户端连接...')

# 等待客户端连接
client_socket, client_address = server_socket.accept()
print('客户端已连接:', client_address)

# 接收客户端发送的数据
data = client_socket.recv(1024)
print('收到数据:', data.decode())
count=0
while True:
    # 发送响应数据给客户端
    response_data = input("请输入：")
    response_data = str(response_data)
    if response_data=='50':
        break
    client_socket.sendall(response_data.encode())
    print("发送数据:",response_data)
    #time.sleep(2)
    #count+=1
# 关闭客户端连接
client_socket.close()

# while True:
#     a = raw_input("请输入：")
#     print(a,type(a))
#     if a=="z": 
#         break